class Solution(object):
    def combinationSum2(self, candidates, target):
        res = []
        candidates.sort()
        self.dfs(candidates, 0, target, [], res)
        return res
    def dfs(self, cands, ind, target, path, res):
        if target == 0:
            res.append(path)
            return
        if target < 0:
            return
        for i in range(ind, len(cands)):
            if i>ind and cands[i]==cands[i-1]:
                continue
            self.dfs(cands, i+1, target-cands[i], path+[cands[i]], res)

print Solution().combinationSum2([10,1,2,7,6,1,5],8)
